package com.zhentao.userLocal;


/**
 * @Date 2024/2/24 10:56
 * @Author mhy
 **/
public class UserThreadLocalUtil {
    private final static ThreadLocal<Long> USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 获取用户
     */
    public static Long getUser() {
        return USER_THREAD_LOCAL.get();
    }

    /**
     * @description: 设置用户id
     * @author: muhaoyang
     * @date: 2024/12/18 9:40
     * @param: [id]
     * @return: void
     **/
    public static void setUser(Long id) {
        USER_THREAD_LOCAL.set(id);
    }

    /**
     * 清理用户
     */
    public static void clear() {
        USER_THREAD_LOCAL.remove();
    }
}
